#define __LIBRARY__
#include <unistd.h>
#include <errno.h>
#include <asm/segment.h>
#include <linux/kernel.h>


char name_store[23] = {0};

int sys_iam(char *name)
{
    int k = 0;
    // calculate the len
    while (get_fs_byte(name+k) != '\0')
    {
        k++;
    }
    if (k > 23)
    {
        return -EINVAL;
    }
    else 
    {
        int i = 0;
        for (i = 0; i < k; i++)
        {
            name_store[i] = get_fs_byte(name + i);
        }
        name_store[i] = '\0';
        return k;
    }
    
}

int sys_whoami(char *name, unsigned int size) 
{
    int len = 0;
    while (name_store[len] !='\0')
    {
        len++;
    }

    if (size < len)
    {
        return -EINVAL;
    }

    int i = 0;
    for (i = 0; i < len; i++)
    {
        put_fs_byte(name_store[i], name+i);
    }
    name[i] = '\0';
    return len;
}